home *** CD-ROM | disk | FTP | other *** search
File List | 1983-11-17 | 12.5 KB | 282 lines |
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-1
-
-
-
- page 55,132
- ;------------------------------------------------------------------------------
- ;PASSWORD.ASM (creates PWORD.SYS, device driver)
- ;
- ;DOS 2.00 Device driver forces user to enter password on booting up
- ;and disables Ctrl-Break.
- ;
- ;After assembly: link PASSWORD (ignore "no STACK" error)
- ; exec2bin PASSWORD PASSWORD.SYS
- ; place DEVICE=PASSWORD.SYS in CONFIG.SYS file
- ; reboot system with Ctrl-Alt-Del
- ; answer prompt with: PassWord <enter>
-
- 0000 dev_seg segment
- 0000 pword_device proc far
- assume cs:dev_seg,ds:dev_seg,es:dev_seg
-
- ;-------------------------------
- ;The following lines are the device header, which must exist for
- ;every device. This file has only one device, and it works with
- ;character I/O. It doesn't actually handle any I/O services,
- ;but it's easier to create a character device.
-
- 0000 pword_dev_header: ;label for the start of the device driver
-
- 0000 FF FF FF FF next_dev_ptr dd -1 ;only 1 device is defined in this file
- 0004 8000 dev_attribute dw 8000h ;character device (simpler that way)
- 0006 0070 R strategy_ptr dw strategy ;the installation proc
- 0008 007B R interrupt_ptr dw interrupt ;the proc that handles all service requests
- 000A 50 41 53 53 57 4F device_name db 'PASSWORD' ;8-byte string of device name
- 52 44
-
- ;--- This is the stroage area for the password --
- ;--- The first byte is the length (0-16) --------
- ;--- The following characters are the password --
- ;--- Only an exact match will allow the system --
- ;--- to continue the boot process ---------------
-
- 0012 08 50 61 73 73 57 password_store db 8,'PassWord'
- 6F 72 64
- 001B 09 [ db $-password_store dup(' ') ;leave room for a
- 20
- ]
-
- ;16 character password
-
- 0024 10 in_buf_max db 16 ;input buffer for reading password from user
- 0025 ?? in_buf_len db ? ;it is set up for DOS service OAH, BUFFERED_INPUT
- 0026 10 [ in_buf db 16 dup(?)
- ??
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-2
-
-
-
- ]
-
-
- ;----- The STRATEGY proc stores ES:BX request header pointer here
- ;----- The INTERRUPT proc retrieves it
-
- 0036 request_ptr label dword ;defined as double word for LES opcode
- 0036 ???? req_ptr_off dw ? ;and as two words for MOV opcodes
- 0038 ???? req_ptr_seg dw ?
-
-
-
- 003A dummy_iret: ;Ctrl-Break vector is pointed here, so it
- 003A CF iret ;does nothing. Break is not recognized.
-
-
-
- ;------------------messages----------------------------------------------------
- ;These messages are expected to be output via the ANSI.SYS device,
- ;so it should be installed (named in the CONFIG.SYS file) before
- ;this PWORD device.
- ;If you don't want to use ANSI.SYS, remove the ESC sequences in the messages.
-
- = 000A lf equ 0ah
- = 000D cr equ 0dh
- = 001B esc equ 1bh
-
- 003B 0D 0A 1B 5B 30 6D msg_1 db cr,lf,esc,'[0m' ;make output visible
- 0041 45 6E 74 65 72 20 db 'Enter Password: '
- 50 61 73 73 77 6F
- 72 64 3A 20
- 0051 1B 5B 38 6D 24 db esc,'[8m$' ;make input invisible
-
- 0056 0D 0A 1B 30 6D msg_2 db cr,lf,esc,'0m' ;make output visible
- 005B 50 61 73 73 77 6F db 'Password accepted.',cr,lf,'$'
- 72 64 20 61 63 63
- 65 70 74 65 64 2E
- 0D 0A 24
-
-
-
- ;==============================================================================
- ;STRATEGY procedure
- ;Just saves the request header pointer for the INTERRUPT proc
-
- 0070 strategy proc far
- assume cs:dev_seg
-
- 0070 2E: 89 1E 0036 R mov cs:req_ptr_off,bx
- 0075 2E: 8C 06 0038 R mov cs:req_ptr_seg,es
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-3
-
-
-
- 007A CB ret ;far return to DOS
- 007B strategy endp
-
-
-
- ;==============================================================================
- ;INTERRUPT procedure
- ;Processes the command indicated in the request header.
-
- 007B interrupt proc far
- assume cs:dev_seg,ds:nothing, es:nothing
- 007B 1E push ds ;preserve all registers
- 007C 06 push es
- 007D 50 push ax
- 007E 53 push bx
- 007F 51 push cx
- 0080 52 push dx
- 0081 57 push di
- 0082 56 push si
- 0083 8C C8 mov ax,cs ;make DS address the
- 0085 8E D8 mov ds,ax ;program data area
-
- 0087 2E: C4 1E 0036 R les bx,request_ptr ;get the pointer saved by
- 008C 26: 8A 47 02 mov al,es:[bx+2] ;fetch the command
- 0090 3C 00 cmp al,0
- 0092 74 15 je init_fn ;only valid request in INI
- 0094 error_exit:
- 0094 26: 81 4F 03 8003 or word ptr es:[bx+3],8003H ;indicate error cod
- ;"Unknown command"
-
- ;---- interrupt service request has been handled.
- ;---- Set he "done flag" and return to DOS.
-
- 009A common_exit:
- 009A 26: 81 4F 03 0100 or word ptr es:[bx+3],100H ;set the done bit
- 00A0 5E pop si
- 00A1 5F pop di
- 00A2 5A pop dx
- 00A3 59 pop cx
- 00A4 5B pop bx
- 00A5 58 pop ax
- 00A6 07 pop es
- 00A7 1F pop ds
- 00A8 CB ret ;far return
-
-
- ;---- Only the INIT function is handled by the PWORD device
- ;---- all other requests are routed through the error_exit.
-
- ;----------------------------------
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-4
-
-
-
- ;INIT_FN procedure
- ;prompts the user for a password, keeps prompting until correct entry
- ;received, Passes the address of this proc back to DOS as the end-of-driver
- ;address so that a minimum amount of storage is used.
-
- 00A9 init_fn proc near
-
- 00A9 06 push es
-
- ;--------------
- ;The following 4 lines eliminate Ctrl-Break from having
- ;any effect on the system, unless another program
- ;KEYBOARD_BREAK vector is altered (BASIC does that).
-
- 00AA B8 0000 mov ax,0
- 00AD 8E C0 mov es,ax
- 00AF 26: C7 06 006C 003A R mov word ptr es:[1Bh*4],offset dummy_iret
- 00B6 26: 8C 0E 006E mov word ptr es:[1Bh*4+2],cs
- 00BB EB 06 jmp short no_beep
- 00BD try_again:
- 00BD B0 07 mov al,7 ;bel character
- 00BF B4 0E mov ah,0EH ;WRITE_TTY service
- 00C1 CD 10 int 10h
- 00C3 no_beep:
- 00C3 BA 003B R mov dx,offset msg_1 ;"Enter Password:"
- 00C6 B4 09 mov ah,9 ;DOS print string service
- 00C8 CD 21 int 21H
-
- 00CA BA 0024 R mov dx,offset in_buf_max
- 00CD B4 0C mov ah,0Ch ;clear input buffer and..
- 00CF B0 0A mov al,0Ah ;input a line of character
- 00D1 CD 21 int 21H
- 00D3 8C C8 mov ax,cs
- 00D5 8E C0 mov es,ax ;set ES to target password
- ;DS already points to user
- 00D7 BE 0025 R mov si,offset in_buf_len
- 00DA B5 00 mov ch,0
- 00DC 8A 0C mov cl,[si]
- 00DE 3A 0D cmp cl,[di] ;are lengths the same?
- 00E0 75 DB jne try_again
- 00E2 47 inc di ;point to first characters
- 00E3 46 inc si ;of both strings
- 00E4 F3/ A6 rep cmpsb ;all chars the same?
- 00E6 75 D5 jne try_again ;no, start over
-
- 00E8 BA 0056 R mov dx,offset msg_2 ;"Password accepted"
- 00EB B4 09 mov ah,9
- 00ED CD 21 int 21H
-
- ;---- now exit from INIT procedure -----------------------------
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-5
-
-
-
- ;---- retain only the minimum amount of code -------------------
- ;---- to handle erroneous service requests ---------------------
-
- 00EF 07 pop es
- 00F0 26: C7 47 0E 00A9 R mov word ptr es:[bx+0EH],offset init_fn
- 00F6 26: 8C 4F 10 mov word ptr es:[bx+10H],cs
-
-
- 00FA EB 9E jmp common_exit
- 00FC init_fn endp
-
- 00FC interrupt endp
- 00FC pword_device endp
- 00FC dev_seg ends
- end pword_dev_header ;must specify end for EXE2
-
- The Microsoft MACRO Assembler 11-17-83 PAGE Symbols-1
-
-
-
- Segments and groups:
-
- N a m e Size align combine class
-
- DEV_SEG. . . . . . . . . . . . . 00FC PARA NONE
-
- Symbols:
-
- N a m e Type Value Attr
-
- COMMON_EXIT. . . . . . . . . . . L NEAR 009A DEV_SEG
- CR . . . . . . . . . . . . . . . Number 000D
- DEVICE_NAME. . . . . . . . . . . L BYTE 000A DEV_SEG
- DEV_ATTRIBUTE. . . . . . . . . . L WORD 0004 DEV_SEG
- DUMMY_IRET . . . . . . . . . . . L NEAR 003A DEV_SEG
- ERROR_EXIT . . . . . . . . . . . L NEAR 0094 DEV_SEG
- ESC. . . . . . . . . . . . . . . Number 001B
- INIT_FN. . . . . . . . . . . . . N PROC 00A9 DEV_SEG Length =0053
- INTERRUPT. . . . . . . . . . . . F PROC 007B DEV_SEG Length =0081
- INTERRUPT_PTR. . . . . . . . . . L WORD 0008 DEV_SEG
- IN_BUF . . . . . . . . . . . . . L BYTE 0026 DEV_SEG Length =0010
- IN_BUF_LEN . . . . . . . . . . . L BYTE 0025 DEV_SEG
- IN_BUF_MAX . . . . . . . . . . . L BYTE 0024 DEV_SEG
- LF . . . . . . . . . . . . . . . Number 000A
- MSG_1. . . . . . . . . . . . . . L BYTE 003B DEV_SEG
- MSG_2. . . . . . . . . . . . . . L BYTE 0056 DEV_SEG
- NEXT_DEV_PTR . . . . . . . . . . L DWORD 0000 DEV_SEG
- NO_BEEP. . . . . . . . . . . . . L NEAR 00C3 DEV_SEG
- PASSWORD_STORE . . . . . . . . . L BYTE 0012 DEV_SEG
- PWORD_DEVICE . . . . . . . . . . F PROC 0000 DEV_SEG Length =00FC
- PWORD_DEV_HEADER . . . . . . . . L NEAR 0000 DEV_SEG
- REQUEST_PTR. . . . . . . . . . . L DWORD 0036 DEV_SEG
- REQ_PTR_OFF. . . . . . . . . . . L WORD 0036 DEV_SEG
- REQ_PTR_SEG. . . . . . . . . . . L WORD 0038 DEV_SEG
- STRATEGY . . . . . . . . . . . . F PROC 0070 DEV_SEG Length =000B
- STRATEGY_PTR . . . . . . . . . . L WORD 0006 DEV_SEG
- TRY_AGAIN. . . . . . . . . . . . L NEAR 00BD DEV_SEG
-
- Warning Severe
- Errors Errors
- 0 0